package cc.geguol.iodemo.bufferinputstream;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 作者：13687
 * 日期：2017/6/17
 * 项目：IODemo
 * 描述：通过字节缓冲区读取文件
 */
public class BufferStreamDemo {
	public static void main(String[] args) throws IOException {
		// 输入流进行包装 它自己应该是自带缓冲区
//		BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream("./img/iofamily.png"));
		MybufferStream bufferedInputStream = new MybufferStream(new FileInputStream("./img/iofamily.png"));
		BufferedOutputStream fileOutputStream =  new BufferedOutputStream(new FileOutputStream("bufferIS.png"));
		int by = 0;//每次读取一个字节
		while ((by=bufferedInputStream.read())!=-1){
		   fileOutputStream.write(by);
		}
		fileOutputStream.close();
		bufferedInputStream.close();
	}
}
